package zzc.javaWeb.javaWebHomew.servlet;


import zzc.javaWeb.javaWebHomew.dao.homeDaoimp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/del")
public class delServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        String _id = req.getParameter("id");
        int id = Integer.parseInt(_id);
        System.out.println("要执行删除的用户id为："+id);
        homeDaoimp homeDaoimp = new homeDaoimp();
        try {
            int flag = homeDaoimp.deleteByID(id);
            if (flag==1){
                resp.sendRedirect("/Jer/home.jsp");
            }else {
                resp.sendRedirect("/Jer/del.jsp");
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }

    }
}
